using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using HengTong.Model.Db.SupplyChain.Material;
using Microsoft.EntityFrameworkCore;


namespace HengTong.ViewModel.SupplyChain.SysMaterialAttributeVms
{
    public partial class SysMaterialAttributeBatchVm : BaseBatchVM<SysMaterialAttribute, SysMaterialAttributeBatchEdit>
    {
        public SysMaterialAttributeBatchVm()
        {
            ListVM = new SysMaterialAttributeListVm();
            LinkedVM = new SysMaterialAttributeBatchEdit();
        }

        public override bool DoBatchDelete()
        {
            var ids = Ids.Where(e => Guid.TryParse(e, out _)).Select(Guid.Parse).ToList();
            if (ids.Any())
            {
                DC.Set<SysMaterialAttributeValue>()
                    .Where(e => ids.Contains(e.AttributeId.Value))
                    .ExecuteDelete();
                Ids = ids.Select(e => e.ToString()).ToArray();
            }
            return base.DoBatchDelete();
        }
    }

	  /// <summary>
    /// Class to define batch edit fields
    /// </summary>
    public class SysMaterialAttributeBatchEdit : BaseVM
    {

      protected override void InitVM()
      {
      }

    }

}
